<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="utf-8">
    <title>企业信息统计</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
</head>
<style>
    .Right {
        width: 100%;
        overflow-y: auto;
    }

    .widthle {
        width: 35%;
        display: inline-block;
        text-align: right;
    }

    .widthle25 {
        width: 25%;
        display: inline-block;
        text-align: right;
    }

    .widinput {
        width: 60% !important;
    }

    xm-select {
        min-height: 30px;
        line-height: 30px;
    }

</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container"
     style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">


    <!--筛选行-->
    <from id = "form-search">
    <div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 10px;">
        <div class="layui-row">
            <!--计划类别-->
            <div class="layui-col-md3">
                <lebel class="widthle">企业名称:</lebel>
                <input type="text" class="widinput" style="border: 1px solid #DDDDDD" name="companyName" id="companyName"
                       autocomplete="off" placeholder="">
            </div>
<#--            <div class="layui-col-md3">-->
<#--                <span class="widthle">资质名称:</span>-->
<#--                <input type="text" class="widinput" style="border: 1px solid #DDDDDD" name="certName" id="certName"-->
<#--                       autocomplete="off" placeholder="">-->
<#--            </div>-->
            <div class="layui-col-md3">
                <span class="widthle"> 注册地点:</span>
                <select name="province" class="ml8 "  id="province"  onchange="provinceChange(this)"   style="width: 120px;"
                        lay-verify="required" lay-ignore>
                    <option value="">全部</option>
                    <#list provincelist as vo>
                        <option value="${vo.code}">${vo.name}</option>
                    </#list>
                </select>
            </div>
            <div class="layui-col-md2">
                <select name="city" id="city" class="ml8 " lay-filter="city" lay-verify="required"  style="width: 120px;"
                        style="margin-left: 0px" lay-ignore   >
                    <option value="">全部</option>
                </select>
            </div>
            <div class="layui-col-md1" style="text-align: end;width: 20%;float: right;">
                <input class="layui-btn layui-btn-normal" style="border-radius:5px;" type="button" value="筛选"
                       onclick="query()">
                <input class="layui-btn layui-btn-normal ml10" type="button"
                       style="border-radius:5px;background-color: #FF5722;" value="重置"
                       onclick="resetQuery()">
            </div>
        </div>
        </form>
    </div>



<div class="layui-container"
     style="background-color: #ffffff;width:96%;margin-top:30px;padding:16px;border-radius: 10px">
    <div class="layui-row">
        <div style=" height: 50px;margin-top: 20px;">
            <@shiro.hasPermission name="search:export">
                <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">
            </@shiro.hasPermission>
            <@shiro.hasPermission name="search:view">
                <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">
            </@shiro.hasPermission>
        </div>
        <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<#-- 可以多选的下拉框 -->
<script src="${re.contextPath}/plugin/layui/xm-select.js"></script>
<!-- 公共配置第三方组件 -->
<script type="text/javascript">
    layui.config({
        version: false,
        debug: false,
        base: "${re.contextPath}/plugin/layui/lay/extra/"
    })

</script>
<script type="text/javascript">
    var defaultTabInd = 0;
    var layer;
    var form = layui.form;
    var table = null;
    var _xstjlcpselect;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;


    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#beginDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
        layui.use('table', function () {
            table = layui.table;
            element = element;
            //方法级渲染
            tableIns = table.render({
                id: 'tableList',
                elem: '#tableList',
                url: '/search/decision/selectComTjList',
                height: "auto",
                page: true,
                cols: [[
                    {
                        title: '序号', width: '10%', align: 'center', templet: function (res) {
                            return res.LAY_INDEX;
                        }
                    },
                    {
                        field: 'id', title: 'id', align: 'center', width: '10%', sort: true, hide: true
                    },
                    {
                        field: 'companyName', title: '企业名称', align: 'center', width: '40%', sort: true
                    },
                    {
                        field: 'zcdProvince', title: '注册地址(省)', align: 'center', width: '25%', sort: true
                    },
                    {
                        field: 'zcdCity', title: '注册地址(市)', align: 'center', width: '25%', sort: true
                    },
                    // {
                    //     field: 'companyName', title: '企业名称', align: 'center', width: '20%', sort: true
                    //     ,templet(d){
                    //         debugger
                    //      return d.companyName+"("+d.username+")";
                    //     }
                    // },
                    // {
                    //     field: 'num', title: '资质证书数量', align: 'center', width: '15%', sort: true
                    // },
                    // {
                    //     field: 'certName', title: '资质证书名称', align: 'center', width: '15%', sort: true
                    //     , templet: function (d) {
                    //         if(d.certName){
                    //             return '<span class="cursor" style="color: blue;" onclick="zsDetail(\'' + d.id + '\',\'' + d.companyName + '\')">' + d.certName + '</span>';
                    //         }else{
                    //             return "";
                    //         }
                    //     }
                    // },
                    // {
                    //     field: 'zcdd', title: '注册地址', align: 'center', width: '15%', sort: true
                    // },
                    // {
                    //     field: 'linkPerson', title: '联系人', align: 'center', width: '10%', sort: true
                    // },
                    // {
                    //     field: 'phoneNumber', title: '联系方式', align: 'center', width: '15%', sort: true
                    // }

                ]],
                done: function (res, currentCount) {
                    //***重点***：table渲染完成后渲染element进度条
                    element.render();
                    $(".layui-table-page select").css("width", "80px");

                }
            });

        });

    });

    function query() {
        var companyName =  $('#companyName').val();
        var certName =  $('#certName').val();
        var province =  $('#province').val();
        var city =  $('#city').val();
        jsondata = {
            companyName: companyName,
            certName:certName,
            province:province,
            city:city
        };
        table.reload('tableList', {where: jsondata});
    }

    function resetQuery() {
        $('#form-search').find('input[type=text],select,input[type=number]').each(function() {
            $(this).val('');
        });
        var jsondata = {
            companyName: '',
            certName: '',
            province: '',
            city: ''
        }
        table.reload('tableList', {where: jsondata});
    }

    function userCertDetail(id) {
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var certName = certName;
        var url = "/search/personTj/certTjDetail?id=" + id;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }



    function zsDetail(id,companyName) {
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var certName = certName;
        var url = "/search/decision/certTjDetail?id=" + id+"&companyName="+encodeURI(companyName);
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }


    function provinceChange(object) {
        $("#city").empty();
        $("#city").append('<option value="">全部</option>')
        var code = $(object).find('option:selected').val();
        if (code == "") {
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $(object).next().empty().append("<option value=''>选择市</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    };

    //导出excel
    function exportTable(){
        var companyName =  $('#companyName').val();
        var province =  $('#province').val();
        var city =  $('#city').val();
        var url= '/search/buProjectInfo/exportTableQy?companyName='+companyName+'&province='+province+'&city='+city;
        location.href = url;
    }
    //预览excel
    function viewTable(){
        var companyName =  $('#companyName').val();
        var certName =  $('#certName').val();
        var province =  $('#province').val();
        var city =  $('#city').val();
        var jsondata = {
            companyName: companyName,
            certName:certName,
            province:province,
            city:city
        };
        layerAjax('/search/buProjectInfo/viewTableQy', jsondata, '', function (d) {
            if(d.flag){
                if(d.data){
                    var w = ($(window).width()*0.8);
                    var h = ($(window).height()*0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + d.data, 'width=1200px;height=800px;', '{}')
                }
            }else {
                layer.msg(d.msg, {icon: 2});
            }
            console.log(d);
        });
    }

    $(function () {
        //回车事件
        $(document).keydown(function(e){
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                query();
            }
            return true;
        });
    })
</script>
</body>

</html>